<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('用户余额变动列表')" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label class="text-center">客户名称：</label>
                            </li>
                            <li>
                                <select name="userId" class="userChoose form-control" onchange="$.table.refresh()"><option value="">全部</option></select>
                            </li>
                            <li class="select-time">
                                <label>操作时间：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginOperateTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endOperateTime]"/>
                            </li>
                            <li>
                                <label>发生事件：</label>
                                <select name="evenId" class="form-control" th:with="type=${@dict.getType('pay_type')}" onchange="$.table.refresh()">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="location.reload()"><i class="fa fa-refresh"></i>&nbsp;刷新</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: select2-js" />
    <th:block th:include="include :: jquery-cxselect-js" />
    <script th:inline="javascript">

        var payTypeDatas = [[${@dict.getType('pay_type')}]];

        $(function() {
            var options = {
                url: ctx + "user/account/list",
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                modalName: "用户余额变动",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'uaId',
                    title: '主键id',
                    visible: false
                },
                {
                    field: 'userName',
                    width: '15',
                    widthUnit: '%',
                    title: '用户名'
                },
                {
                    field: 'beforeBalance',
                    title: '之前余额'
                },
                {
                    field: 'thisAmount',
                    title: '金额'
                },
                {
                    field: 'afterBalance',
                    title: '当前余额'
                },
                {
                    field: 'operateTime',
                    width: '15',
                    widthUnit: '%',
                    title: '操作时间'
                },
                {
                    field: 'evenId',
                    title: '发生事件',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(payTypeDatas, value);
                    }
                },
                {
                    field: 'orderId',
                    title: '订单号'
                },
                {
                    field: 'remark',
                    width: '18',
                    widthUnit: '%',
                    title: '备注'
                }]
            };
            $.table.init(options);
        });

        //拉取用户信息
        $(function () {
            $.ajax({
                type: "post",
                url: ctx + "hh/user/selectList",
                data: {},
                success: function(result) {
                    if (result.code == 0) {
                        $('#formId').cxSelect({
                            required: false,
                            firstTitle: '全部',
                            selects: ['userChoose'],
                            jsonName: 'name',
                            jsonValue: 'id',
                            data: result.data
                        });
                    }
                }
            })
        });
    </script>
</body>
</html>